package com.yimi.yinhepda.views.load_module.module;

import android.text.TextUtils;

import com.alibaba.fastjson.JSONObject;
import com.pda.uce.commom.util.AppUtil;
import com.pda.uce.commom.util.NetUtils;
import com.pda.ym.callbacks.UICallBack;
import com.pda.ym.net.NetRequest;
import com.pda.ym.utils.Constants;
import com.pda.ym.utils.SharedPreferUtil;
import com.yimi.yinhepda.entity.response.KuaidiMergeLoadSwitchResponse;
import com.yimi.yinhepda.entity.response.QueryCheckMacEnableResponse;

import java.util.HashMap;
import java.util.Map;

import rx.functions.Action1;

/***
 * 检验快递合并装车开关是否开
 */
public class CheckMergeLoadModule {
    public static CheckMergeLoadModule uploadErrorModule;

    public static CheckMergeLoadModule getInstance() {
        if (uploadErrorModule == null) {
            synchronized (CheckMergeLoadModule.class) {
                if (uploadErrorModule == null) {
                    uploadErrorModule = new CheckMergeLoadModule();
                }
            }
        }
        return uploadErrorModule;
    }


    public void checkMergeSwitch() {
        if (AppUtil.isConnected()) {
            NetUtils.getKuaiYunHttp(new Action1<JSONObject>() {
                @Override
                public void call(JSONObject jsonObject) {
                    if (jsonObject.getBoolean("success")) {
                        JSONObject jsonData = jsonObject.getJSONObject("data");
                        if (jsonData.containsKey("merge_load_switch")) {
                            JSONObject jsonMergeLoad = jsonData.getJSONObject("merge_load_switch");
                            SharedPreferUtil.getInstance().setValue(SharedPreferUtil.KUAIDI_MERGE_LOAD_SWITCH, jsonMergeLoad.getString("1"));
                        }
                    }
                }
            }, Constants.URL_GET_QUERY_DICT + "merge_load_switch");
        }
    }

}
